import { CarPageResult, CarQueryParam } from '@/types'
import request from '@/utils/request'
import { AxiosPromise } from 'axios'

/**
 * 获取车辆分页列表
 *
 * @param queryParams
 */
export function listCarPages(queryParams: CarQueryParam): AxiosPromise<CarPageResult> {
    return request({
        url: '/car/api/v1/cars',
        method: 'get',
        params: queryParams
    })
}

/**
 * 获取车辆详情
 *
 * @param id
 */
export function getCarFormDetail(id: number) {
    return request({
        url: '/car/api/v1/cars/' + id,
        method: 'get'
    })
}

/**
 * 添加车辆
 *
 * @param data
 */
export function addCar(data: object) {
    return request({
        url: '/car/api/v1/cars',
        method: 'post',
        data: data
    })
}

/**
 * 更新车辆
 *
 * @param id
 * @param data
 */
export function updateCar(id: number, data: object) {
    return request({
        url: '/car/api/v1/cars/' + id,
        method: 'put',
        data: data
    })
}